﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace OnlineCooperation
{
    /// <summary>
    /// Handler1 的摘要说明
    /// </summary>
    public class TeamFileHd : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["TeamID"] == null || context.Session["TeamID"].ToString() == "")
                return;

            context.Response.ContentType = "text/plain";
            string action = context.Request["action"];
            if (action == "root")
            {

                string path = context.Server.MapPath("AppData/Team/" + context.Session["TeamID"].ToString())+"/";//必须在 文件夹 后边多加  / ,不然 获得的路径错误！！！
                path = path.Replace("\\", "/"); //这里必须对 反斜杠 \   进行替换！！！
                
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                context.Response.Write(path);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}